package org.mech.sefer.client.ui.controller;

import javax.annotation.PostConstruct;
import javax.annotation.Resource;

import org.mech.sefer.client.ui.task.executor.TaskExecutor;
import org.mech.sefer.client.ui.task.executor.impl.TaskExecutorImpl;
import org.mech.sefer.event.Event;
import org.mech.sefer.event.EventSource;
import org.mech.sefer.event.Handler;
import org.mech.sefer.event.bus.EventBus;

public abstract class Controller implements EventSource {
	
	@Resource(name="eventBus")
	private EventBus eventBus;
	
	private TaskExecutor executor = new TaskExecutorImpl();
	
	@Override
	public void fireEvent(Event<? extends Handler> event) {
		eventBus.fireEvent(event);
	}
	
	@PostConstruct
	public void register(){
		onRegister();
	}
	
	protected abstract void onRegister();

	public EventBus getEventBus() {
		return eventBus;
	}

	public TaskExecutor getExecutor() {
		return executor;
	}

	public void setExecutor(TaskExecutor executor) {
		this.executor = executor;
	}

	public void setEventBus(EventBus eventBus) {
		this.eventBus = eventBus;
	}
	

}
